<?php
require_once dirname(__FILE__).'/autoload.php';

$HTTP_PROXY_LIST = '
110.153.9.250:80
61.135.179.167:8080
124.126.126.7:80
183.60.212.122:80
125.39.66.153:80
180.180.121.165:8080
116.226.47.78:8080
125.39.21.23:8080
114.80.136.112:7780
116.228.55.217:8000
190.79.196.245:8080
180.180.121.228:8080
180.136.134.133:8001
180.180.121.104:8080
125.216.144.199:8080
61.152.108.187:80
222.124.33.36:8080
203.189.136.199:8080
180.245.235.37:8080
91.233.188.154:8080
211.151.186.228:80
203.146.82.253:80
195.140.190.146:8080
210.51.23.91:8080
125.39.66.162:80
177.107.97.245:8080
221.10.40.237:80
203.191.150.11:8081
121.199.43.32:8080
61.167.137.26:8080
219.72.225.251:80
118.186.253.226:8000
125.39.68.226:80
110.77.247.228:8080
136.0.16.210:7808
91.241.21.10:8080
222.124.15.124:8080
89.179.244.102:8080
202.98.123.126:8080
69.197.132.80:7808
221.238.28.158:8081
211.167.64.112:8080
180.180.121.13:80
118.99.81.113:8080
222.132.29.10:8080
190.57.232.154:80
124.119.50.254:80
111.13.87.150:80
110.232.72.174:8080
110.78.145.151:8080
118.99.85.206:8080
200.195.166.234:8080
125.39.66.164:80
181.119.15.190:8080
218.24.15.98:8000
198.52.247.103:8080
124.126.42.11:8080
222.141.199.150:80
114.80.157.181:7780
221.7.145.42:8080
61.166.55.153:11808
119.167.231.73:8080
218.91.206.146:8001
200.192.252.246:8080
77.94.48.5:80
118.99.76.28:8080
119.161.222.19:80
202.10.42.73:8080
115.25.216.6:80
221.174.16.8:80
175.25.243.26:80
59.151.37.8:8028
114.80.136.164:7780
61.147.107.18:808
123.234.230.45:808
61.164.42.147:80
61.134.53.87:80
210.101.131.232:8080
125.39.66.163:80
124.232.164.176:80
219.159.105.180:8080
119.6.73.138:8080
186.24.34.178:8080
61.19.42.244:80
218.25.17.246:80
183.136.146.110:8085
212.111.4.134:8080
116.236.216.116:8080
122.11.35.236:80
137.135.100.29:8080
192.64.11.124:80
79.175.187.2:8080
218.5.74.174:80
124.232.164.177:80
119.97.146.16:8080
211.167.112.14:80
175.106.8.106:8080
123.164.148.132:80
119.167.231.72:8080
95.87.239.115:8080
42.96.168.171:80
61.153.98.6:8080
180.173.89.208:8080
42.62.29.104:8080
213.203.182.116:8080
111.13.87.150:80
116.228.55.184:80
202.85.221.169:80
200.54.92.187:80
42.62.29.104:8080
221.10.40.237:80
111.1.32.53:8080
119.167.231.72:8080
122.48.244.124:80
211.155.111.52:80
122.11.35.236:80
91.99.101.218:80
113.212.125.30:8080
201.62.56.1:8080
211.161.152.109:80
175.25.243.26:80
219.159.105.180:8080
202.98.123.126:8080
187.55.178.58:8080
188.32.40.52:8080
80.53.218.186:80
197.162.116.37:80
187.78.153.228:80
211.167.105.77:80
118.98.35.251:8080
197.160.71.76:8080
124.81.113.183:8080
58.215.179.194:80
210.51.2.57:8080
180.250.82.188:8080
190.238.239.208:8080
111.1.55.18:8080
82.78.161.56:8080
190.96.64.234:8080
210.101.131.232:8080
190.39.58.83:8080
201.242.174.230:8080
61.167.49.188:8080
201.210.177.171:8080
201.208.122.88:8080
190.153.98.78:8080
177.21.227.177:8080
41.75.111.162:8080
175.25.243.22:80
111.91.122.114:8080
62.0.3.157:80
61.153.236.30:80
218.87.219.48:8080
81.25.26.1:8080
84.40.111.206:8080
125.163.127.220:80
125.39.21.23:8080
119.97.146.16:8080
201.243.203.227:8080
182.52.235.18:80
124.119.50.254:80
200.192.214.138:8080
202.149.69.125:8080
1.179.144.98:8080
200.42.56.146:8080
203.19.4.241:8080
195.140.190.146:8080
216.100.93.79:8080
180.250.43.83:8080
89.190.195.170:8080
200.192.252.246:8080
190.0.16.58:8080
125.39.163.161:8080
110.77.138.92:8080
115.69.223.74:8080
190.198.129.90:8080
201.20.104.170:8080
110.77.194.129:80
5.98.86.141:8080
198.49.70.103:8080
187.16.32.101:8080
189.41.246.16:8080
222.124.218.164:8080
190.57.232.156:80
194.213.60.222:8080
190.201.31.139:8080
182.52.235.117:8080
137.135.98.170:8080
180.94.86.162:80
190.198.91.236:8080
36.74.160.143:80
187.115.44.229:80
180.254.76.78:8080
103.247.102.218:8080
118.97.102.50:8080
94.184.245.9:8080
42.96.168.171:80
82.207.68.142:8080
182.52.235.33:80
125.167.34.210:8080
94.198.38.246:8080
46.229.136.224:8080
182.52.235.37:80
190.205.99.129:8080
124.232.164.177:80
190.36.225.132:8080
190.74.25.206:8080
200.63.85.9:8080
180.180.122.214:8080
85.233.90.6:80
190.36.210.16:8080
197.160.112.215:8080
36.73.6.21:80
190.205.201.78:8080
180.149.76.6:8080
206.251.60.135:8080
114.255.7.186:80
118.99.107.122:8080
177.98.31.240:8080
190.233.60.232:80
125.160.71.103:8080
117.121.204.74:8080
200.93.67.132:8080
180.252.128.80:8080
94.136.138.83:8080
110.77.219.194:8080
124.126.126.7:80
61.135.179.167:8080
183.60.212.122:80
218.5.74.174:80
61.152.108.187:80
211.151.186.228:80
119.254.90.18:8080
125.39.66.162:80
116.226.47.78:8080
110.173.0.18:80
98.190.245.179:8080
201.33.29.86:8080
180.180.121.164:80
197.162.14.195:80
180.173.89.208:8080
219.150.204.30:80
61.153.98.6:8080
221.176.14.72:80
216.152.145.4:8080
186.24.34.178:8080
77.94.48.5:80
115.25.216.6:80
121.199.51.128:8080
211.155.111.51:80
219.72.225.251:80
124.126.127.7:80
199.21.112.52:8080
182.52.235.9:8080
202.152.6.10:8080
111.1.32.51:8080
190.206.228.173:8080
189.44.113.186:8080
190.94.220.81:8080
2.188.16.5:8080
190.153.120.25:8080
116.236.216.116:8080
187.120.253.1:8080
211.155.111.53:80
211.155.111.50:80
118.97.36.244:8080
202.159.6.130:8080
106.3.43.73:80
202.63.225.246:8080
200.35.220.180:8080
187.120.38.61:8080
221.0.90.54:8080
124.232.164.176:80
119.167.231.73:8080
177.23.200.102:8080
201.87.241.46:8080
190.164.108.101:8080
201.20.177.171:8080
222.141.199.150:80
59.57.15.71:80
121.199.43.32:8080
175.100.4.123:8080
31.135.196.229:8080
201.62.57.1:8080
110.153.9.250:80
85.135.52.30:8080
202.159.20.137:8080
78.130.201.110:8080
222.169.60.5:80
189.89.170.182:8080
189.114.75.22:8080
211.142.236.132:80
61.53.64.37:8080
190.121.135.178:8080
186.89.247.60:8080
59.46.67.108:8080
180.180.121.134:8080
177.21.253.18:8080
202.51.110.74:8080
175.139.212.164:8080
186.179.111.172:8080
175.106.8.106:8080
202.90.198.78:8080
41.46.213.218:8080
182.52.235.31:8080
201.12.116.18:8080
190.38.115.18:8080
60.55.43.64:80
211.167.112.14:80
202.138.245.42:8080
118.99.84.170:8080
222.74.98.234:8080
64.22.103.91:8080
180.253.120.104:8080
60.223.255.141:8080
115.238.244.121:80
110.96.193.7:80
221.238.140.164:8080
222.89.226.18:80
61.167.137.26:8080
181.119.15.190:8080
201.57.242.194:80
118.97.130.10:8080
119.6.73.138:8080
190.206.118.233:8080
218.25.17.246:80
118.97.191.203:8080
203.146.82.253:80
200.84.107.166:8080
31.13.22.213:8080
201.20.177.185:8080
211.142.236.133:8080
202.127.99.11:8080
186.211.6.165:8080
177.3.47.223:8080
95.171.53.243:80
177.101.8.13:8080
89.179.102.107:8080
27.131.190.66:8080
125.39.21.20:80
211.138.156.199:80
190.73.197.239:8080
61.164.184.66:8080
177.39.209.43:8080
91.233.188.154:8080
190.151.122.38:8080
61.136.93.38:8080
124.74.249.15:80
202.122.14.21:8080
204.106.251.245:8080
110.232.72.174:8080
110.77.200.187:8080
118.97.63.227:8080
222.124.15.124:8080
190.85.115.42:8080
41.130.160.65:80
118.98.161.242:8080
110.77.194.15:8080
201.15.125.75:8080
190.239.247.104:8080
200.84.166.164:8080
180.180.123.119:80
190.75.72.111:8080
116.231.205.13:8080
190.200.26.49:8080
190.206.204.234:8080
181.225.47.137:8080
190.200.7.26:8080
190.75.91.67:8080
94.23.53.128:80
103.247.219.20:8080
202.75.18.110:8080
123.232.119.125:80
177.99.11.92:8080
80.240.35.5:8080
120.138.97.225:8080
222.180.173.6:8080
41.191.52.115:8080
186.90.153.133:8080
189.105.32.21:8080
74.118.91.238:8080
190.38.124.151:8080
221.7.213.216:8080
110.77.197.8:8080
190.29.30.114:8080
203.201.163.122:8080
190.201.177.122:8080
86.120.196.242:8080
178.212.124.111:8080
84.124.12.2:8080
186.95.35.44:8080
201.242.132.150:8080
201.243.133.242:8080
61.7.134.57:8080
201.209.98.82:8080
';

$arrProxyList = array_unique(array_filter(explode('<br />', nl2br(trim($HTTP_PROXY_LIST)))));
foreach ($arrProxyList as &$proxy) {
    $proxy = preg_replace('#\s+#', '', $proxy);
}unset($proxy);

shuffle($arrProxyList);

$GlobalCountIncr = array();
$GlobalCountIncr['errno'] =array();
$GlobalCountIncr['ok']=array();

foreach($arrProxyList as $proxyServer){
	$proxy = $proxyServer;
	$ch = curl_init();
	$url='http://imail.sinaapp.com/ip.php';
    curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, $ua[mt_rand(0, count($ua) - 1)]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    $result = curl_exec($ch);
	var_dump($result);
    if ($curl_errno = curl_errno($ch)) {
        $GlobalCountIncr['errno'][$proxy] ++;
        log::w('proxy[' . $proxy . '] fetch errno:' . $curl_errno . ',error:' . curl_error($ch));
		file_put_contents(dirname(__FILE__).'/Slow-Proxy.txt',$proxyServer.PHP_EOL,8);
    } else {
        $GlobalCountIncr['ok'][$proxy] ++;
        log::n('proxy[' . $proxy . '] fetch success,cost[' . (microtime(true) - $intTime) . ']');
		log::n('result:'.$result);
		$arrIpHttp=explode(':',$result);
		$arrIpProxy=explode(':',$proxyServer);
		if($arrIpHttp[0]==$arrIpProxy[0]){
			echo $proxyServer.PHP_EOL;
			file_put_contents(dirname(__FILE__).'/Fast-Proxy.txt',$proxyServer.PHP_EOL,8);
		}
    }
    curl_close($ch);
}


?>